package com.mashibing.tank.pojo;

import com.mashibing.tank.utils.ImageUtil;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

/**
 * @ClassName ResourceMgr
 * @Description TODO 静态读取图片缓存
 * @Author zhangjunhao
 * @DATE 2023/8/27 23:00
 */
public class ResourceMgr {
    public static BufferedImage goodTankL, goodTankR, goodTankU, goodTankD;
    public static BufferedImage badTankL, badTankR, badTankU, badTankD;
    public static BufferedImage bulletL, bulletD, bulletU, bulletR;
    public static BufferedImage[] explodes = new BufferedImage[16];


    /*
    * 静态加载图片,启动项目便加载图片
    * */
    static {
        try {

            goodTankU = ImageIO.read(new File("src\\com\\mashibing\\tank\\images\\GoodTank1.png"));
            goodTankL = ImageUtil.rotateImage(goodTankU,-90);
            goodTankR = ImageUtil.rotateImage(goodTankU,90);
            goodTankD = ImageUtil.rotateImage(goodTankU,180);

            badTankU = ImageIO.read(new File("src\\com\\mashibing\\tank\\images\\BadTank1.png"));
            badTankL = ImageUtil.rotateImage(badTankU,-90);
            badTankR = ImageUtil.rotateImage(badTankU,90);
            badTankD = ImageUtil.rotateImage(badTankU,180);


            bulletU = ImageIO.read(new File("src\\com\\mashibing\\tank\\images\\bulletU.png"));
            bulletL = ImageUtil.rotateImage(bulletU,-90);
            bulletR = ImageUtil.rotateImage(bulletU,90);
            bulletD = ImageUtil.rotateImage(bulletU,180);

            for (int i = 0; i < 16; i++) {
                explodes[i] = ImageIO.read(new File("src\\com\\mashibing\\tank\\images\\e"+(i+1)+".gif"));
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }


}
